<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>

  <script>
    let obj1 = {
      date: new Date(),
      error: new Error('错误'),
      reg: new RegExp('\\w+'),
      fun: () => { console.log('fun') },
      undef: undefined,
      nan: NaN,
      infinity: Infinity,

    }
    // 1. 日期对象变成字符串
    // 2. error对象、正则对象变为空对象
    // 3. undefind和函数会丢失
    // 4. NaN和infinity会变成null
    // 5. 对象属性是构造函数创建的，其constructor会丢失
    // 6. 对象循环引用使用Json.parse(Json.stringify())会报错

    console.log('obj1:', obj1)
    let obj2 = JSON.parse(JSON.stringify(obj1))
    console.log('obj2:', obj2)
  </script>
</body>

</html>